#pragma once
#include<iostream>
#include"AsioIOServicePool.h"
#include<boost/asio.hpp>
#include<memory>
#include<map>
#include<mutex>
#include"Csession.h"
using boost::asio::ip::tcp;

class Csession;
class CServer
{
public:
	CServer(boost::asio::io_context& io_context,int port);
	~CServer();
	void ClearSession(std::string);
private:
	void HandleAccept(shared_ptr<Csession>, const boost::system::error_code& error);
	void StartAccept();
	boost::asio::io_context& _io_context;
	int _port;
	tcp::acceptor _acceptor;
	std::map<std::string, shared_ptr<Csession>> _sessions;
	std::mutex _mutex;
};

